package com.tangcco.lockwell.repository;

import com.tangcco.lockwell.domain.AnswerContentRecord;
import lombok.Data;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface AnswerContentRecordMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(AnswerContentRecord record);

    int insertSelective(AnswerContentRecord record);

    AnswerContentRecord selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(AnswerContentRecord record);

    int updateByPrimaryKeyWithBLOBs(AnswerContentRecord record);

    int updateByPrimaryKey(AnswerContentRecord record);

    /**
     * 查询用户的回答内容
     * @param questionId
     * @param answerUserId
     * @return
     */
    List<AnswerContentRecord> selectByUser(@Param("examPaperId") Integer examPaperId,
                                           @Param("questionId") Integer questionId,
                                           @Param("answerUserId") Integer answerUserId,
                                           @Param("type") Integer type);
    /**
     * 查询用户的回答内容
     * @param questionId
     * @param answerUserId
     * @return
     */
    List<AnswerContentRecord> selectByUserAndIndex(@Param("examPaperId") Integer examPaperId,
                                           @Param("questionId") Integer questionId,
                                           @Param("answerUserId") Integer answerUserId,
                                           @Param("answerOptionsIndex") Integer answerOptionsIndex,
                                           @Param("type") Integer type);

    /**
     * 删除用户的回答内容
     * @param questionId
     * @param answerUserId
     * @return
     */
    int deleteByUser(@Param("examPaperId") Integer examPaperId,
                    @Param("questionId") Integer questionId,
                     @Param("answerUserId") Integer answerUserId,
                     @Param("type") Integer type);
    /**
     * 删除用户的回答内容（英语根据题目索引删除）
     * @param questionId
     * @param answerUserId
     * @param answerOptionsIndex
     * @return
     */
    int deleteByUserAndIndex(@Param("examPaperId") Integer examPaperId,
                    @Param("questionId") Integer questionId,
                     @Param("answerUserId") Integer answerUserId,
                     @Param("answerOptionsIndex") Integer answerOptionsIndex,
                     @Param("type") Integer type);

    /**
     * 根据试卷ID和用户ID查询回答内容
     * @param examPaperId
     * @param userId
     * @return
     */
    List<AnswerContentRecord> selectByExamPaperIdAndUserId(@Param("examPaperId") Integer examPaperId,
                                                           @Param("answerUserId") Integer userId,
                                                           @Param("type") Integer type);
    /**
     * 根据试卷ID和用户ID及题目ID查询回答内容
     * @param examPaperId
     * @param userId
     * @return
     */
    List<AnswerContentRecord> selectByExamPaperIdAndUserIdAndQuestionId(@Param("examPaperId") Integer examPaperId,
                                                           @Param("answerUserId") Integer userId,
                                                           @Param("type") Integer type, @Param("questionId") Integer questionId);
    /**
     * 根据试卷ID和用户ID查询回答内容
     * @param examPaperId
     * @param userId
     * @return
     */
    List<AnswerContentRecord> selectByExamPaperIdAndUserIdGroup(@Param("examPaperId") Integer examPaperId,
                                                                @Param("answerUserId") Integer userId,
                                                                @Param("type") Integer type);
}